﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SchEdu.Framework.DataModel;
using SchEdu.Framework.Validators;

namespace SchEdu.Framework.Objective
{
    class AverageCompletionTime : Objective
    {
        public AverageCompletionTime()
            : base()
        {
        }
        public AverageCompletionTime(SchEduData schEduData, SchEduDataSet.SolutionRow solution)
            : base(schEduData, solution)
        {
        }
        protected override void Logic()
        {
            double averageCompletionTime = 0;
            double totalCompletionTime = 0;


            foreach (SchEduDataSet.OrderRow order in SchEduData.Order)
            {
                totalCompletionTime += (int)order.ProcessingTime;
            }

            averageCompletionTime = totalCompletionTime / SchEduData.Order.Count;

            GeneratePerformanceRow();

            performance.Value = Math.Round(averageCompletionTime,2);


        }

        public override AboutInfo AboutInfo
        {
            get
            {
                AboutInfo aboutInfo = new AboutInfo();
                aboutInfo.Title = "Average Completion Time";
                aboutInfo.Guid = new Guid("{5560A948-6EC6-4af8-9AAD-66D5BF4BE452}");
                aboutInfo.Description = Resources.AverageCompletionTimeDescription;
                return aboutInfo;
            }
        }

    }
}
